package com.queen.restaurant.service;

import java.text.SimpleDateFormat;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.queen.restaurant.dao.CommentCourseDao;
import com.queen.restaurant.dao.OrderItemDao;
import com.queen.restaurant.domain.CommentCourse;
import com.queen.restaurant.domain.CommentRestaurant;
import com.queen.restaurant.domain.Order;
import com.queen.restaurant.domain.OrderItem;

@Service
public class CommentCourseService {

	@Autowired
	private CommentCourseDao commentCourseDao;
	@Autowired
	private OrderItemDao orderItemDao;
	
	public void insertCommentCourse(CommentCourse commentCourse){
		OrderItem orderItem = commentCourse.getOrderItem();
		orderItem.setCanComment(false);
		orderItemDao.save(orderItem);
		
		SimpleDateFormat dateFm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //格式化当前系统日期
		String commentTime = dateFm.format(new java.util.Date());
		
		commentCourse.setCommentTime(commentTime);
		commentCourseDao.save(commentCourse);
	}
}
